def reverse(x: int) -> int:
    s = str(x)
    if '-' in s:
        k = s[1:]
        k = k[::-1]
        x = -1*int(k)
        if (-2)**31 < x < 2**31-1:
            return x
        else:
            return 0
    else:
        if (-2)**31 < int(s[::-1]) < 2**31-1:
            return int(s[::-1])
        else:
            return 0


print(reverse(-123123))
print(reverse(123121231231231231233))
